 <style>
     .ttl{width:70px;text-align:right;}
     .pop_cont_input{width:100%;}
     .pop_cont_input ul {width:100%;}
     .pop_cont_input ul li {height:35px;}
     .pop_cont_input{line-height:30px;}
     .pop_cont_input input{pading:0px 5px;}
     .pop_cont_input select{height:28px;}
     .pop_cont .pop_cont_input li{margin: 0px 0px;}
     .pop_cont .pop_cont_input li .textbox{border:1px #d2d2d2 solid; width:120px; display:inline-block;}

     .pop_cont {
         background: white;
         min-width: 300px;
         height: auto;
         overflow: hidden;
         position: absolute;
         top: 5%;
         left: 50%;
         margin-left: -49%;
         border-radius: 5px 5px 0 0;
     }
     .pop_cont .btm_btn {padding:0px 0px;}
     .blank{width:100%;height:10px;overflow:hidden;}
.bixuan{color:red;}
 </style>
 <!--引入JS-->
<script type="text/javascript" src="/static/admin/js/ajaxfileupload.js?t=1"></script>
 <link rel="stylesheet" type="text/css" href="/static/My97DatePicker/skin/WdatePicker.css" />
<script charset="utf-8" src="/static/My97DatePicker/WdatePicker.js"></script>
 <div class="pop_cont" style="width:98%;">
       <input type="hidden" value="<?php echo $id; ?>" id="editId" />
       <!--title-->
       <h3><?php echo $title;?><span class="falseBtn" style="color:red;float:right;font-size:18px;cursor:pointer;">X</span></h3>
       <!--content-->
        <form autocomplete="off" action="#" id="myform"></form>
       <div class="pop_cont_input">
            <div id="relationSourch"></div>
            <div id="ajaxGetDataConts"></div>
            <div id="relationResult"></div>
           <!--bottom:operate->button-->
           <div class="btm_btn" style="height: 50px;">
               <input type="button" value="确认" class="input_btn trueBtn" /> <input
                   type="button" value="取消" class="input_btn falseBtn" />
           </div>
       </div>

     <div class="blank"></div>
       <!--bottom:operate->button-->
      
      </div>
      
      <script>

      $(function(){


          //相关选择开始
          var dataString='<?php echo $dataString;?>';//已选择中的
          var msgshow="<?php echo $msgshow; ?>";//窗口隐藏后回显的id为该值的input框
          var allRelationSelectResult=<?php echo json_encode($allRelationSelectResult,true); ?>;

          $("body").on('click','.itemRelationCheckbox',function(){
              var selectID = $(this).parent().parent().attr("data-id");
              var selectName = $(this).parent().parent().attr("data-name");
              var item = {selectID:selectID,selectName:selectName};
              dealRelationSelectOption(item)
          });
          function dealRelationSelectOption(item)
          {
              var flag = -1;
              $.each(allRelationSelectResult,function(i,v){
                        if(v.selectID ==item.selectID) {
                            flag=i;
                            return;
                        }
              })
              if(flag==-1){
                  allRelationSelectResult.push(item);
              } else{
                  allRelationSelectResult.splice(flag,1);
              }
          }
          $("body").on('click','.relationSelectPage',function(){
              var page=$(this).attr("page");
              var cparam={
                  page:page
              };
             getShopList(cparam);
          });
          function getShopList(cparam){
              var relationUrl="/admin/relationselect/selectdata";
              var param={
                  msgshow:msgshow,
                  dataString:dataString
              };
              var requestParam = combineTwoObject(cparam,param);
              AjaxRequest(relationUrl,requestParam,function(data) {
                  if (data.err == 0) {
                      var html =makeShopData(data.data);
                      $("#ajaxGetDataConts").html(html);
                  } else {

                  }
              });
          }
          getShopList({page:1});
          function makeShopData(data){
              console.log(data)
                 var list = data.data;
                 var html ='<table class="table" style="margin-top:10px;">\n' +
                         '<tr>\n' +
                         '<th style="width:100px;"></th>\n' +
                         '<th style="width:100px;">ID</th>\n' +
                         '<th style="width:500px;">产品名称</th>\n' +
                         '<th style="width:100px;">状态</th>\n' +
                     '</tr>';
                 $.each(list,function(i,v){
                     var flag =-1;
                     $.each(allRelationSelectResult,function(itemKey,itemVal){
                         if(itemVal.selectID ==v.id) {
                             flag=itemKey;
                             return;
                         }
                     })
                     html +='<tr data-id="'+v.id+'" data-name="'+v.name+'">';
                     html +='<td style="text-align:left;">';
                     if(flag>=0) {
                         html +='<input type="checkbox" value="' + v.id + '"  class="itemRelationCheckbox" name="itemRelationCheckbox[]" checked>';
                     } else {
                         html +='<input type="checkbox" value="' + v.id + '"  class="itemRelationCheckbox" name="itemRelationCheckbox[]">';
                     }
                     html +='</td>';
                     html +='<td style="text-align:left;">'+v.id+'</td>';
                     html +='<td style="text-align:left;">'+v.name+'</td>';
                     html +='<td style="text-align:left;">'+v.statsMapper+'</td>';
                     html +='</tr>';
                 });
                 html +='</table>';
                 html += generaPageHtml(data.current_page,data.last_page,data.per_page,data.total);
                 return html;
          }
          //选择相关结束
     	 
	       $(".trueBtn").unbind().bind("click",function(){

               var that =this;
               $(".pop_bg").fadeOut();
               $(".pop_bg").html('');

               var html='';
               $.each(allRelationSelectResult,function (i,v) {
                    html +='<div class="relationResultCSS" data-id="'+v.selectID+'" data-name="'+v.selectName+'">';
                    html +=v.selectName;
                    html +='<div class="relationResultClose" title="删除">X</div>';
                    html +='</div>';

                });

               $("#<?php echo $msgshow ?>").html(html);
		  });
		   //弹出：取消或关闭按钮
		   $(".falseBtn").unbind().bind("click",function(){
			 $(".pop_bg").fadeOut();
		   });
 	});
      </script>